Page({
  data: {
    holidayList: []
  },
  
  onLoad: function() {
    this.calculateHolidaysLeft();
  },
  
  calculateHolidaysLeft: function() {
    const today = new Date();
    const currentYear = today.getFullYear();
    const holidays = [
      { name: '元旦', date: '01-01' },
      { name: '春节', date: '02-10' }, // 这里的日期仅为示例，需要根据实际日期进行调整
      { name: '清明节', date: '04-04' },
      { name: '劳动节', date: '05-01' },
      { name: '端午节', date: '06-12' }, // 端午节日期每年不同，需要动态计算
      { name: '中秋节', date: '09-10' },
      { name: '国庆节', date: '10-01' }
    ];
    
    const holidayList = holidays.map(holiday => {
      const holidayDate = new Date(currentYear, ...this.parseDate(holiday.date));
      const diff = holidayDate - today;
      return {
        name: holiday.name,
        daysLeft: diff > 0 ? Math.ceil(diff / (1000 * 60 * 60 * 24)) : 0
      };
    });
    
    this.setData({ holidayList });
  },

  parseDate: function(dateStr) {
    const [month, day] = dateStr.split('-');
    return [parseInt(month) - 1, parseInt(day) - 1];
  }
});